#include "Student.h"
#include "University.h"
#include <iostream>

using namespace std;



Student_t::Student_t(StudentImpl* pImpl, University_t* pUv) : Observer(pUv){

	m_pStudentImpl = pImpl;
}

void Student_t::Update(Subject* changedSbj){
	m_pStudentImpl->update(changedSbj);
}

int Student_t::getTuition() const{
	return m_pStudentImpl->getTuition();
}

Student_t::~Student_t(){
	delete m_pStudentImpl;
}

StudentImpl::StudentImpl(University_t* pUniversity,Faculty_t* pFaculty, int t){

	m_pFaculty	=	pFaculty;
	m_pUV		=	pUniversity;
	m_tuition		=	t;
}

StudentImpl::~StudentImpl() {}

int StudentImpl::getTuition() const{
	return m_tuition;
}

void StudentImpl::update(Subject* pChangedSbj){

	if ((void*)pChangedSbj == (void*)m_pUV){
		int p = m_pUV->getPrice();
		if (p != m_tuition) {
			cout << "Tuition was changed from" << m_tuition << "to" << p << endl;
			m_tuition = p;
		}
	} 

}

FOH_Student::FOH_Student(University_t* pUniversity,Faculty_t* pFaculty, int t) : StudentImpl(pUniversity,pFaculty,t) {}

void FOH_Student::update(Subject* pChangedSbj){

	StudentImpl::update(pChangedSbj);
	if ((void*)pChangedSbj == (void*)m_pFaculty){
		//do nothing!
	}

}

ESF_Student::ESF_Student(University_t* pUniversity,Faculty_t* pFaculty, int t) : StudentImpl(pUniversity,pFaculty,t) {};


void ESF_Student::update(Subject* pChangedSbj){
	
	StudentImpl::update(pChangedSbj);
	if ((void*)pChangedSbj == (void*)m_pFaculty){
		cout << "I was informed that the lecture was canceled." << endl;
	}
}

